package ua.kpi_java_training.zabrodskyi.module3;

import java.util.Scanner;

/**
 * The class is intended for setting and storage of the initial data for work of
 * the program, set by the user.
 * 
 * @author Maksym Zabrodskyi
 * @version 25-Jun-2013
 */
public final class Settings {
	private final static int WIDTH_DEFAULT = 10;
	private final static int HEIGTH_DEFAULT = 10;
	private static int widthEnvironment = WIDTH_DEFAULT;
	private static int heightEnvironment = HEIGTH_DEFAULT;
	private int numberPredators;
	private int numberVictims;
	private int numberBarriers;
	private int lengthLife;

	/**
	 * Set up all initial parameters for work of the program by means of a call
	 * of other methods.
	 */
	public void setUp() {
		Scanner scanner = new Scanner(System.in);
		setWidthEnvironment(scanner);
		setHeightEnvironment(scanner);
		setPredators(scanner);
		setVictims(scanner);
		setBarriers(scanner);
		setLengthLife(scanner);
	}

	/**
	 * Setting of value of width of environment.
	 * 
	 * @param scanner
	 *            - The system scanner of data input from the keyboard.
	 */
	private void setWidthEnvironment(Scanner scanner) {
		widthEnvironment = Input.getPositiveNumber(scanner,
				"Enter width of Environment:");
	}

	/**
	 * Setting of value of height of environment.
	 * 
	 * @param scanner
	 *            - The system scanner of data input from the keyboard.
	 */
	private void setHeightEnvironment(Scanner scanner) {
		heightEnvironment = Input.getPositiveNumber(scanner,
				"Enter height of Environment:");
	}

	/**
	 * Setting of value of quantity of predators in environment.
	 * 
	 * @param scanner
	 *            - The system scanner of data input from the keyboard.
	 */
	private void setPredators(Scanner scanner) {
		numberPredators = Input.getPositiveNumber(scanner,
				"Enter the number of Predators:");
	}

	/**
	 * Setting of value of quantity of victims in environment.
	 * 
	 * @param scanner
	 *            - The system scanner of data input from the keyboard.
	 */
	private void setVictims(Scanner scanner) {
		numberVictims = Input.getPositiveNumber(scanner,
				"Enter the number of Victims:");
	}

	/**
	 * Setting of value of quantity of barriers in environment.
	 * 
	 * @param scanner
	 *            - The system scanner of data input from the keyboard.
	 */
	private void setBarriers(Scanner scanner) {
		numberBarriers = Input.getPositiveNumber(scanner,
				"Enter the number of Barriers:");
	}

	/**
	 * Setting of value of length of a life (quantity of cycles) in environment.
	 * 
	 * @param scanner
	 *            - The system scanner of data input from the keyboard.
	 */
	private void setLengthLife(Scanner scanner) {
		lengthLife = Input.getPositiveNumber(scanner,
				"Enter the number of cycles of Life:");
	}

	/**
	 * Returns value of width of environment.
	 * 
	 * @return integer - value of width.
	 */
	public static int getWidth() {
		return widthEnvironment;
	}

	/**
	 * Returns value of height of environment.
	 * 
	 * @return integer - value of height.
	 */
	public static int getHeight() {
		return heightEnvironment;
	}

	/**
	 * Returns quantity of predators in environment.
	 * 
	 * @return integer - value of quantity of predators.
	 */
	public int getNumberPredators() {
		return numberPredators;
	}

	/**
	 * Returns quantity of victims in environment.
	 * 
	 * @return integer - value of quantity of victims.
	 */
	public int getNumberVictims() {
		return numberVictims;
	}

	/**
	 * Returns quantity of barriers in environment.
	 * 
	 * @return integer - value of quantity of barriers.
	 */
	public int getNumberBarriers() {
		return numberBarriers;
	}

	/**
	 * Returns value of length of a life (quantity of life cycles) in
	 * environment.
	 * 
	 * @return integer - value of length of a life.
	 */
	public int getLengthLife() {
		return lengthLife;
	}

}
